import Vue from 'vue'
var common = function () {
    return {
        saveChart: function (myChart,imageName) {
            var url = myChart.getConnectedDataURL({
                pixelRatio: 5, //导出的图片分辨率比率,默认是1
                backgroundColor: "#fff", //图表背景色
                excludeComponents: [
                    //保存图表时忽略的工具组件,默认忽略工具栏
                    "toolbox"
                ],
                type: "png" //图片类型支持png和jpeg
            });
            var $a = document.createElement("a");
            var type = "png";
            $a.download = imageName + "." + type;
            $a.target = "_blank";
            $a.href = url;
            var evt = new MouseEvent("click", {
                view: window,
                bubbles: true,
                cancelable: false
            });
            $a.dispatchEvent(evt);
        },
        // 小写转大写
        toUppercase: function (o, parName) {
            if (o && o[parName]) {
                o[parName] = o[parName].toUpperCase();
            }
        }
    }
}();
if (typeof (Vue) == "function") Vue.prototype.common = common;